package com.atguigu.gmall.activity.redis;
/**
 * 加油！你是最胖的
 *
 * @author TaiXiaoDong on 2023/3/24.
 * @version 1.0
 */

import com.atguigu.gmall.activity.util.CacheHelper;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**



 */
@Component
public class MessageReceive {

    /**
     同步状态位消费

     key-value
     skuId 1

     1、本地内容 new

     2、安全
     ConcurrentHashMap

     接收到的数据 ““19:1””

    */
    public void receiveMessage(String msg){

        //判断
        if (!StringUtils.isEmpty(msg)) {

            //处理器数据，去掉双引号
            String message = msg.replaceAll("\"", "");
            //截取
            String[] split = message.split(":");
            //判断
            if (split != null && split.length == 2) {

                //缓存状态位
                CacheHelper.put(split[0],split[1]);
            }
        }

        System.out.println(msg);

    }


}
